/**
 * 
 */
package com.p2p.front.dal.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.p2p.base.dao.BaseMapper;
import com.p2p.base.page.PageVo;
import com.p2p.front.dal.model.MemberPoint;

/**
 * @author ruiqi
 *
 */
public interface MemberPointDao extends BaseMapper{

	String tableName = "p2p_member_point";
	String columns = "user_id,produce_cumulative,consume_cumulative,level";
	
	@Insert("insert into "+tableName+"("+columns+")values(#{userId},#{produceCumulative},#{consumeCumulative},#{level})")
	void create(MemberPoint memberPoint);
	
	@Update("update "+tableName+" set produce_cumulative=#{produceCumulative},consume_cumulative=#{consumeCumulative},level=#{level} where user_id=#{userId}")
	boolean update(MemberPoint memberPoint);
	
	@ResultMap("MemberPointResultMap")
	@Select("select "+columns+" from "+tableName+" where user_id=#{userId}")
	MemberPoint getByUserID(String userId);
	
	@ResultMap("MemberPointResultMap")
	@Select("select "+columns+" from "+tableName+" where user_id=#{userId} for update")
	MemberPoint selectForUpdateByUserId(String userId);
	
	@Select("select * from p2p_member_point")
	List<Map<String,Object>> listAllUserPoint(PageVo form);
	
	List<MemberPoint> queryByUserIdList(List<String> userIdList);
	
	
}
